% This is a function for generation Mackey-Glass Time Series
% Fix the value of n = 1000 to 10000
% MG Series is periodic for tau<17 otherwise non-periodic
% Initial values are generated randomly using rand function
% Euler's method is for solving MG diffrential equation
% ds(t)/dt = 0.2s(t-tau)/(1+s(t-tau)^10) - 0.1s(t)

function mydata = mgts(n);
a = 0.2;
b = .1;
tau = 30;
for t = 1:n
    if t<= tau
        s(t) = rand;
    else
        s(t) = .9*s(t-1)+(0.2*s(t-tau))/(1+s(t-tau)^10);
    end
end
mgs = s';

mydata = mgs(1001:2000)';
t=1001:2000;
plot(t, mydata);